package com.etc.RCCPU005.controller;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.etc.RCCPU005.pojo.Product;
import com.etc.RCCPU005.service.ProductService;
import com.etc.common.Code;
import com.etc.common.CodeMessage;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
/**
 * 
 * Filename:    ProductController.java  
 * Description:  产品控制器
 * Copyright:   Copyright (c) 2018-2019 All Rights Reserved.
 * Company:     chinasofti.com Inc.
 * @author:     qinxiaodong 
 * @version:    1.0  
 * Create at:   2020年3月12日 下午8:29:54  
 *  
 * Modification History:  
 * Date         Author      Version     Description  
 * ------------------------------------------------------------------  
 * 2020年3月12日      qinxiaodong      1.0         1.0 Version  
 *
 */
@RestController
public class ProductController {
	
	@Autowired
	ProductService productServiceImpl;
	
//	查询所有的产品
	@RequestMapping("/selectAllProducts.action")
	public CodeMessage selectAllProducts() {
		List<Map> list = productServiceImpl.selectAllProducts();
		return CodeMessage.success(Code.SUCESS, null, list);	
	}
	
//	按照类型查询产品
	@RequestMapping("/selectAllProductsByType.action")
	public String selectAllProductsByType(String tid,Integer page,Integer limit) {
		PageHelper.startPage(page, limit);
		List<Map> list = productServiceImpl.selectAllProductsByType(tid);
		PageInfo<Map> p = new PageInfo<>(list);
		return CodeMessage.success(Code.SUCESS, "检索成功", p, true);
	}

}
